package com.snow.campuslink.project.result;

import com.snow.campuslink.project.constant.Constant.SysConstant;
import lombok.Data;

/**
 * @ClassName Result
 * @Description TODO
 * @Author Gaosl
 * @Date 2020/12/3 20:31
 * @Version 1.0
 */
@Data
public class Result {


    /**
     * 记录行为的结果，默认0表示成功，-1表示失败
     */
    private String code;

    /**
     * 记录返回信息
     */
    private String message;

    /**
     * 记录行为获取的数据
     */
    private Object data ;



    private Result(){}
    public static Result success(){
        Result result = new Result();
        result.setCode(SysConstant.ResponseCode.SUCCESS);
        result.setMessage("SUCCESS");
        return result;
    }
    public static Result fail(){
        Result result = new Result();
        result.setCode(SysConstant.ResponseCode.FAIL);
        result.setMessage("FAIL");
        return result;
    }

    public static Result partFail(){
        Result result = new Result();
        result.setCode(SysConstant.ResponseCode.PART_FAIL);
        result.setMessage("PART_FAIL");
        return result;
    }


    public Result code(String code){
        this.setCode(code);
        return this;
    }
    public Result message(String message){
        this.setMessage(message);
        return this;
    }

    public Result data( Object value){
        this.data=value;
        return this;
    }


}
